Skip to content

Conversation

@walshmm
Copy link
Collaborator

@walshmm walshmm commented Dec 5, 2025

Description of work

This pr enables users of snapred to supply a user generated pixel mask to be used as part of diffraction calibration.

Explanation of work

A lot of the work in this pr was around all the edge cases in the sub-algorithms that didnt account for fully masked groups.
The other bits of work involved orchestrating the mask, and combining it with the potentially existing diffraction calibration mask.

I also refactored the diffcal section of the happy path tests to be much more modular.
This way I was able to include an additional test with the same sequence of events, except with the addition of testing for user masks.
A user mask influences the following steps of the workflow, so it necessitated a whole new run.

To test

Observe what the new integration test does.

If you would like to test it manually, you will need to load your target input workspace, or one with the same instrument as it.
Then mask out a whole group, extract the mask, and name it MaskWorkspace_2.
(I think I need to write a defect, as I encountered MaskWorkspace_1's not properly being sent along, though that may be my fault?)
Now run diffcal with this mask selected, the tweak peaks view should have at least one less graph if you masked out a group.
Run to completion.

Link to EWM item

EWM#3645

Verification

  • the author has read the EWM story and acceptance critera
  • the reviewer has read the EWM story and acceptance criteria
  • the reviewer certifies the acceptance criteria below reflect the criteria in EWM

Acceptance Criteria

This list is for ease of reference, and does not replace reading the EWM story as part of the review. Verify this list matches the EWM story before reviewing.

  • acceptance criterion 1
  • acceptance criterion 2

walshmm and others added 8 commits October 8, 2025 16:16
fix import path

apparently the auto import logic has changed for the worse

fix fetch diffcal groceries unit test

odd update to try and get github to kick off ci

add test for the combining of masks for diffcal

actually pass the maskworkspace to be used by the backend

update tests to accept maskworkspaces from different states as valid

fix integration tests

added a test to confirm resident masks are filtered if not compatible

change exception type to something not pydantic

up the last couple lines of coverage

update precommit, remove commented out code

fix mock method definition
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 88.05970% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.25%. Comparing base (d3751cf) to head (b5a944a).
⚠️ Report is 2 commits behind head on next.

Files with missing lines Patch % Lines
src/snapred/backend/data/GroceryService.py 76.92% 3 Missing ⚠️
src/snapred/backend/service/CalibrationService.py 93.10% 2 Missing ⚠️
...d/backend/recipe/CalculateDiffCalResidualRecipe.py 0.00% 1 Missing ⚠️
src/snapred/backend/recipe/PixelDiffCalRecipe.py 91.66% 1 Missing ⚠️
src/snapred/backend/service/ReductionService.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next     #658      +/-   ##
==========================================
- Coverage   96.34%   96.25%   -0.10%     
==========================================
  Files          77       77              
  Lines        7010     7052      +42     
==========================================
+ Hits         6754     6788      +34     
- Misses        256      264       +8     
Flag Coverage Δ
integration 49.41% <10.44%> (-0.02%) ⬇️
unittests 95.97% <88.05%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@walshmm walshmm marked this pull request as ready for review December 11, 2025 21:14
Copy link
Contributor

@ekapadi ekapadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got through comments for everything but the tests. I'll go through those next. Most of these comments, with a few exceptions, are just nit-picking. However, they'll probably show a few things that you could help explain!

@walshmm walshmm force-pushed the ewm3645_mask_workspace_diffcal branch from 49e6036 to 6499fcb Compare December 17, 2025 20:43
@walshmm walshmm force-pushed the ewm3645_mask_workspace_diffcal branch from 1bef35a to b720b8c Compare December 17, 2025 20:55
@walshmm walshmm force-pushed the ewm3645_mask_workspace_diffcal branch from 94b6307 to a87bd8f Compare December 17, 2025 21:23
Copy link
Contributor

@ekapadi ekapadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some issues with the way combinePixelMasks creates and uses its <output workspace>. I think I'd prefer that it would explicitly create it, not depending on any "it's the first workspace in the incoming list" type of behavior. The problem is that, in workbench, the user could be working on a bunch of different things at the same time. It is not OK that one of their masks suddenly dissappeared and was re-purposed for SNAPRed's purposes. :)

@walshmm walshmm force-pushed the ewm3645_mask_workspace_diffcal branch from 4026ef5 to 02fdbfe Compare December 18, 2025 19:27
@walshmm walshmm force-pushed the ewm3645_mask_workspace_diffcal branch from 52d1195 to 6fc6cf3 Compare December 18, 2025 19:48
@walshmm walshmm force-pushed the ewm3645_mask_workspace_diffcal branch from bcefcbb to 41f773f Compare January 6, 2026 20:16
@walshmm walshmm force-pushed the ewm3645_mask_workspace_diffcal branch from 9527281 to 3bbab68 Compare January 7, 2026 16:56
@walshmm walshmm force-pushed the ewm3645_mask_workspace_diffcal branch from db1fabc to 85f2b96 Compare January 8, 2026 19:39
Copy link
Contributor

@ekapadi ekapadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran these changes through extensive tests, using various types of input mask, including pathological cases. Several of these tests initially triggered failing edge cases, but all of these have since been fixed to my satisfaction. With the caveat as indicated below: I approve these changes.

During the course this testing, it was noted that there seems to be a rare case which triggers an "LHS != RHS" error (indicating a mismatch of masked group counts during the diagnostics calculation) -- unfortunately we could not then repeat this issue -- it seems to depend either on the specifics of the node it is run on, or possibly something about the history of the GUI actions. Defect EWM12329 "Diffcal Masking Inconsistencies", should cover this case.

@walshmm walshmm merged commit a281a3a into next Jan 12, 2026
10 of 13 checks passed
@walshmm walshmm deleted the ewm3645_mask_workspace_diffcal branch January 12, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants